package com.bolehui.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bolehui.base.result.Result;
import com.bolehui.domain.po.Organizationexperience;
import com.bolehui.domain.vo.OrganizationExVO;
import com.bolehui.mapper.OrganizationexperienceMapper;
import com.bolehui.service.OrganizationexperienceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chendongjie
 * @since 2025-03-18
 */
@Service
public class OrganizationexperienceServiceImpl extends ServiceImpl<OrganizationexperienceMapper, Organizationexperience> implements OrganizationexperienceService {

    @Autowired
    private OrganizationexperienceMapper organizationexperienceMapper;
    @Override
    public Result saveOranEx(OrganizationExVO organizationExVO, Long userId) {
        Organizationexperience organizationexperience = Organizationexperience.builder()
                .clubName(organizationExVO.getClubName())
                .office(organizationExVO.getOffice())
                .dateStart(organizationExVO.getDateStart())
                .dateEnd(organizationExVO.getDateEnd())
                .experienceDesc(organizationExVO.getExperienceDesc())
                .candidateId(userId)
                .build();
        organizationexperienceMapper.insert(organizationexperience);
        return Result.success();
    }

    @Override
    public Result update(OrganizationExVO organizationExVO, Long userId) {
        Organizationexperience organizationexperience = Organizationexperience.builder()
                .clubName(organizationExVO.getClubName())
                .office(organizationExVO.getOffice())
                .dateStart(organizationExVO.getDateStart())
                .dateEnd(organizationExVO.getDateEnd())
                .experienceDesc(organizationExVO.getExperienceDesc())
                .build();
        organizationexperienceMapper.update(organizationexperience, new QueryWrapper<Organizationexperience>().eq("candidate_id", userId));
        return Result.success();
    }
}
